﻿
CREATE VIEW [dbo].[AmixFisaMijlocFixView]
AS
SELECT     IDMijlocFix, NrInventar, NumarDoc, MONTH(DataDoc) AS Luna, YEAR(DataDoc) AS An, 
                      CASE WHEN IDTipDocument = 2 THEN 'INTRARE MIJLOC FIX' WHEN IDTipDocument = 3 THEN 'IESIRE MIJLOC FIX' WHEN IDTipDocument = 4 THEN 'TRANSFER INTERN' WHEN IDTipDocument = 5 THEN
                       'CONSERVARE' WHEN IDTipDocument = 6 THEN 'REACTIVARE' WHEN IDTipDocument = 7 THEN 'MODIFICARE VALOARE' WHEN IDTipDocument = 8 THEN 'MODERNIZARE ' ELSE 'ALT DOCUMENT' END
                       AS Miscare, DataDoc, CASE WHEN IDTipDocument = 2 THEN ValoareInventar WHEN IDTipDocument = 3 THEN 0 WHEN IDTipDocument = 8 AND 
                      ValoareSuplimentara > 0 THEN ValoareSuplimentara ELSE 0 END AS Debit, 
                      CASE WHEN IDTipDocument = 2 THEN 0 WHEN IDTipDocument = 3 THEN ValoareInventar - ValoareAmortizata WHEN IDTipDocument = 8 AND 
                      ValoareSuplimentara < 0 THEN - ValoareSuplimentara ELSE 0 END AS Credit
FROM         dbo.AmixDocumente